﻿@namespace Microsoft.FluentUI.AspNetCore.Components
@inherits FluentComponentBase
@{
    #pragma warning disable 612, 618
}

<div class="fluentui-counterbadge-container" @attributes="@AdditionalAttributes">
    @ChildContent

    @if (Dot)
    {
        <div class="@ClassValue" style="@StyleValue" dot-only></div>
    }
    else
    {
        @* TODO: Remove the below 3 lines once obsolete BadgeContent is removed *@
        if (BadgeContent is not null)
        {
            <div class="@ClassValue" style="@StyleValue" title="@Count">@BadgeContent</div>
        }

        if (BadgeTemplate is not null)
        {
            <div class="@ClassValue" style="@StyleValue" title="@Count">@BadgeTemplate(Count)</div>
        }
        else
        {
            @* TODO: Remove obsolete ShowZero check once it is removed *@
            if (ShowZero && Count == 0 || ShowWhen.Invoke(Count))
            {
                string? text = Count.ToString();
                if (Count > Max)
                {
                    text = $@"{Max}{(ShowOverflow ? "+" : "")}";
                }
                <div class="@ClassValue" style="@StyleValue" title="@Count">@text</div>
            }
        }
    }
</div>
